package com.zb.Service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zb.Service.RecordService;
import com.zb.mapper.RecordMapper;
import com.zb.util.PageUtil10;

@Component
public class RecordServiceImpl implements RecordService{
	@Autowired
	private RecordMapper rm;
	public void getRlist(String starttime,String endtime,String realname,PageUtil10 pu) {
		Map<String, Object> map = new HashMap<String, Object>();
		if(starttime!=null&&!starttime.equals("")){
			map.put("starttime", starttime);
		}
		if(endtime!=null&&!endtime.equals("")){
			map.put("endtime", endtime);
		}
		if(realname!=null&&!realname.equals("")){
			map.put("realname", "%"+realname+"%");
		}
		map.put("index",(pu.getIndex()-1)*pu.getSize());
		map.put("size", pu.getSize());
		pu.setData(rm.getRlist(map));
		this.getRlistCount(starttime, endtime, realname, pu);
	}

	public void getRlistCount(String starttime,String endtime,String realname,PageUtil10 pu) {
		Map<String, Object> map = new HashMap<String, Object>();
		if(starttime!=null&&!starttime.equals("")){
			map.put("starttime", starttime);
		}
		if(endtime!=null&&!endtime.equals("")){
			map.put("endtime", endtime);
		}
		if(realname!=null&&!realname.equals("")){
			map.put("realname", "%"+realname+"%");
		}
		pu.setCount(rm.getRlistCount(map));
	}

	public int addRecord(int uid,String info) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("info", info);
		return rm.addRecord(map);
	}
	
}